let express = require('express')

let app = express()
app.all('*', function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  if(req.method === 'OPTIONS') {
    return res.send()
  }
  next()
})

app.get('/getTreeList', (req, res) => {
  res.json({
    color: 0,
    data: {
      parent: [
        {id: 1, pid: 0, name: '文件夹1'},
        {id: 2, pid: 0, name: '文件夹2'},
        {id: 3, pid: 0, name: '文件夹3'},
        {id: 4, pid: 1, name: '文件夹1-1'},
        {id: 5, pid: 2, name: '文件夹2-1'}
      ],
      child: [
        {id: 10001, pid: 1, name: '文件1'},
        {id: 10002, pid: 1, name: '文件2'},
        {id: 10003, pid: 2, name: '文件2-1'},
        {id: 10004, pid: 2, name: '文件2-2'},
        {id: 10005, pid: 4, name: '文件1-1-1'},
        {id: 10006, pid: 5, name: '文件2-1-1'}
      ]
    }
  })
})

app.listen(3000, () => {
  console.log(`http://localhost:3000/`)
})